package com.example.mapper;

import com.example.dto.UserPageQueryDTO;
import com.example.entity.User;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper

public interface UserMapper {
//    @Select("select * from users")
//    Page pageQuery(UserPageQueryDTO userPageQueryDTO);

    /**
     * 删除
     * @param Sno
     */
    @Delete("delete from users where id=#{id}")
      void dele(Integer Sno);

    /**
     * 查询数据总数
     * @return
     */
    @Select("select count(*) from users")
    public Long count();

    /**
     * 分页查询
     * @param start
     * @param pageSize
     * @return
     */
    @Select("select * from users limit #{start},#{pageSize}")
    public List<User> pag(Integer start,Integer pageSize);

    /**
     * 查询所有
     * @return
     */
    @Select("select * from users")
    Page<User> page();

    /**
     * 插入数据
     * @param user
     */

    @Insert("insert into users (username, name, sex, password, phone_number, state, created_time) VALUES (#{username},#{name},#{sex},#{password},#{phoneNumber},#{state},#{createdTime})")
    void add(User user);

    @Select("select * from users where id = #{id}")
    User see(Integer id);

    void update(User user);
    @Insert("insert into con(conn) values (#{conn})")
    void conAdd(String conn);
}
